<?php
if (isset($_POST['type_name']) && !empty($_POST['type_name'])){
    $type_name=$_POST['type_name'];
    $con=mysqli_connect('localhost','root','root');
    if (!$con){
        die('连接失败'.mysqli_connect_error());
    }
    mysqli_select_db($con,'blog');
    mysqli_set_charset($con,'utf8');
    $sql="insert into blog_type(type_name) values('$type_name')";
    $result=mysqli_query($con,$sql);
    if (!$result){
        echo '保存失败';
    }else{
        header("Location:blogtype_list.php");
    }
    mysqli_close($con);
}else{
    //跳转到指定页面
    header("Location:blogtype_add.html");
}
